feat: Add Custom Token Exhange Support#253
Merged
tanya732 merged 4 commits intoJul 7, 2026
Merged
Conversation
Contributor
Author
|
It looks like your comment only contains a mention with no specific request. The current implementation is in place and all tests are passing locally. Could you clarify what you'd like me to do? For example:
|
kailash-b
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds first-class support for Custom Token Exchange (CTE) the OAuth 2.0 Token Exchange grant (
urn:ietf:params:oauth:grant-type:token-exchange, RFC 8693). This enables applications to exchange an externalsubject_token(for example, an M2M or partner-issued token) for Auth0 tokens.What's Included
New
AuthenticationControllerAPIThis PR introduces four new entry points:
customTokenExchange(token, type)customTokenExchange(token, type, domain)loginWithCustomTokenExchange(token, type)loginWithCustomTokenExchange(token, type, domain)Behavior
Login flow (
loginWithCustomTokenExchange)org_id/org_name(when an organization is configured)openidscope was not requested), the request fails withMISSING_ID_TOKENinstead of returning an unverified success.Utility flow (
customTokenExchange)Domain resolution
The overloads that do not take an explicit domain throw
IllegalStateExceptionwhen the controller is configured with aDomainResolver.Since a
DomainResolverrequires an HTTP request and Custom Token Exchange may execute outside an HTTP request context, callers must use the explicit-domain overload in this configuration.Client-side validation
Introduced
CustomTokenExchangeExceptionto validate inputs before making the request.Validation includes:
Bearer-prefixed subject tokens.Implementation
RequestProcessor.executeCustomTokenExchange(...)delegates toAuthAPI.exchangeToken(...), which is responsible for:Files Changed
AuthenticationController.javaTokenExchangeRequest.java(new)CustomTokenExchangeException.java(new)INVALID_TOKEN_FORMAT,INVALID_TOKEN_TYPE_URI).RequestProcessor.javabuildTokenExchangeRequest(...)andexecuteCustomTokenExchange(...).build.gradlecom.auth0:auth0from 3.5.1 to 3.10.0.Test Plan
AuthenticationControllerTestRequestProcessorTestDomainResolverguardMISSING_ID_TOKENbehaviorTokenExchangeRequestTest